<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title></title>
</head>
<body>
<script type="text/javascript">
	let obj = {
		name : '李唯一',
		age:18
	}

	//用for in 遍历 for in 遍历数组的时候返回的是下标，遍历对象的时候返回的是属性名
	for(let i in obj){
		console.log(i)
	}

	//for of在逼历对象的时候默认是报错的obj is not iterable
	// for(var i of obj){
	// 	console.log(i)
	// }

	for(var i of Object.keys(obj)){
		console.log(i) //遍历属性名
	}
	for(var i of Object.values(obj)){
		console.log(i) //返回属性值
	}

	for(var i of Object.entries(obj)){
		console.log(i) //属性名和属性值组成一个数组
	}
</script>
</body>
</html>